package com.kaikeba.t31.controller;

import com.kaikeba.t31.admin.po.AdminRole;
import com.kaikeba.t31.admin.vo.AdminRoleVo;
import com.kaikeba.t31.core.controller.BaseController;
import com.kaikeba.t31.core.vo.ResponseBean;
import com.kaikeba.t31.service.AdminRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yumingzhi
 * @since 2021-11-14
 */
@RestController
@RequestMapping("/role")
public class AdminRoleController extends BaseController<AdminRoleService, AdminRole> {

    @Autowired
    private AdminRoleService adminRoleService;

    @PostMapping("/saveRole")
    public ResponseBean saveRole(AdminRoleVo entity) throws Exception {
        ResponseBean rm = new ResponseBean();
        try {
            adminRoleService.saveRole(entity);
            rm.setModel(entity);
        } catch (Exception e) {
            e.printStackTrace();
            rm.setSuccess(false);
            rm.setMsg("保存失败");
        }
        return rm;
    }
}

